<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>数组拿出元素</h2>
    <ul>
        <li>pop()：获取并移除数组的头部元素，如果数组为空，返回undefined。</li>
        <li>shift()：获取并移除数组的尾部元素，如果数组为空，返回undefined。</li>
    </ul>
    <script>
        let a = [1,2,3,4,5];
        console.log("a = ",a);

        // 拿出第一个元素
        let value = a.shift();
        console.log("a = ",a,",value = ",value);

        // 拿出最后一个元素
        value = a.pop();
        console.log("a = ",a,",value = ",value);   
    </script>
</body>
</html>